<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      >
    <h:head>
        <title>Fake Main Portal</title>
        
        <link rel="stylesheet" type="text/css" href="CSS/RandallCSS.css" />
        
        <style>

            body{
                margin-top: 50px;
                margin-left:150px;
                margin-right:150px;
            }
            

        </style>

    </h:head>
    <h:body>
            <div class="fixedTopBar">
                CURRENTLY LOGGED IN:
                <br/>
                <h:panelGrid columns="2">
                    <b>User ID: </b> <h:outputText value="#{fakeMainPortalMB.getCustomerID()}"/>
                    <b>Email:</b> <h:outputText value="#{fakeMainPortalMB.getCustomerEmail()}"/>
                    <b>Loyalty Points:</b> <h:outputText value="#{fakeMainPortalMB.getUserLoyaltyPoints()}"/>
                </h:panelGrid>
            </div>
        <br/>
        <br/>
        <br/>       
        <div class="Heading">ADMIN AND STAKEHOLDER</div>
        <h:form styleClass="contentbox">
            <br/><h2 align="center"> TCube, Stakeholder and Outlet Portal</h2>
            <table border="1" style="vertical-align: middle; margin-left:auto; margin-right:auto;">
                <tr><th>Enter Name</th><th>Go</th></tr>
                <tr><td/>
                    <td>   <h:commandButton action="TCubeAdmin/SABM_SM/addStakeholder?faces-redirect=true" value="Log in as Tcube Admin">
                        </h:commandButton></td>
                </tr>
                <tr>
                    <td> <h:inputText id="stakeholderName" value="#{fakeMainPortalMB.stakeholderName}"/></td>

                    <td>   <h:commandButton action="Representative/SABM?faces-redirect=true" value="Log in as stakeholder representative">
                        </h:commandButton></td>
                </tr>
                <tr>
                    <td> <h:inputText id="outletName1" value="#{TrackerOutletAdmin.outletId}"/></td>
                    <td>   <h:commandButton action="OutletManager/IOTR?faces-redirect=true" actionListener="#{TrackerOutletAdmin.accessOutlet(TrackerOutletAdmin.outletId)}" value="Manage This Outlet">
                            
                        </h:commandButton></td>
                </tr></table><br/>
            <table style="vertical-align: middle; margin-left:auto; margin-right:auto;"> 
                <tr>
                    <td><h:commandButton action="#{fakeMainPortalMB.startBilling()}" value="Enable Billing Cycle"/></td>
                    <td><h:commandButton action="#{fakeMainPortalMB.stopBilling()}" value="Disable Billing Cycle"/></td>
                </tr>
            </table><br/><br/>
        </h:form>
        
 
        
        <br/>
        <br/>
        <br/>
        
        
        <div class="Heading">CUSTOMER LOGIN</div>
        <h:form styleClass="contentbox"> 
         <div style="margin-left:30%;">            

            <br/>    
            <br/>
            <br/>
        <!--New login form added by randall, using SM team's session login code in the managed bean-->
             Choose the user account to log in<br/>
  
             <h:selectOneMenu value="#{fakeMainPortalMB.customerEmail}" style="width:220px;">
                <f:selectItems value="#{fakeMainPortalMB.getAllUserEmails()}"/>
             </h:selectOneMenu>
             <h:commandButton action="#{fakeMainPortalMB.login()}" value="Log in" /><br/>
             <br/>
             <br/>               
         </div>      
           <h:commandButton action="ViewCart.xhtml?faces-redirect=true" value="View Cart" style="margin-left:30%;"/>&nbsp; 
           <h:commandButton action="CustomerMainPage.xhtml?faces-redirect=true" value="Customer Main Page"/>&nbsp; 
           <h:commandButton action="customerViewVouchers.xhtml?faces-redirect=true" value="View Reward Vouchers"/>
           <br/>
           <br/>   
        </h:form>
               

        
        <br/>
        <br/>
        <br/>
        
        <div class="Heading">F&amp;B STAKEHOLDER</div>
        <h:form styleClass="contentbox" >
            
            <div style="margin-left:30%;">
            
            <br/>
            <br/>
            <br/>
            Choose a Stakeholder:
            <br/>
             <h:selectOneMenu value="#{fakeMainPortalMB.stakeholderName}" style="width:220px;" onselect="">
                <f:selectItems value="#{fakeMainPortalMB.getAllFoodStakeholderNames()}"/>
             </h:selectOneMenu>
            <h:commandButton action="index.xhtml" value="Show Features"/>
            <br/>
            <br/>
            <br/>
            </div>
            
            
            <div align="center">
                                <b>OUTLETS: </b><br/>
                                <p:dataTable value="#{fakeMainPortalMB.getOutletsbyStakeholder()}" var="o"
                                     styleClass="order-table-shoppingcart"
                                     emptyMessage="No outlets to display"
                                     >

                                    <p:column style="width: 10%">
                                        <f:facet name="header">Outlet ID</f:facet>
                                        #{o.id}
                                    </p:column>

                                    <p:column style="width: 40%">
                                        <f:facet name="header">Outlet Name</f:facet>
                                        #{o.outletName}
                                    </p:column>

                                    <p:column style="width: 40px">
                                        <f:facet name="header">Address</f:facet>
                                        #{o.address}
                                    </p:column>

                                    <p:column style="width: 10%">
                                        <h:commandButton action="TableBooking?faces-redirect=true" value="Go to this outlet">
                                                <f:setPropertyActionListener target="#{fakeMainPortalMB.outletId}" value="#{o.id}" />
                                                <f:setPropertyActionListener target="#{tableBookingMB.customerEmail}" value="#{fakeMainPortalMB.customerEmail}" />
                                                <f:setPropertyActionListener target="#{groupBuyCustManagedBean.customerEmail}" value="#{fakeMainPortalMB.customerEmail}" />                       
                                                <f:setPropertyActionListener target="#{tableBookingMB.outletId}" value="#{o.id}" />      
                                        </h:commandButton>
                                    </p:column>          
                                </p:dataTable>

                                    <br/>
                                    <br/>

                                <b>REWARDS: </b><br/>
                                     <p:dataTable value="#{fakeMainPortalMB.getRewardsbyStakeholder()}" var="o"
                                     styleClass="order-table-shoppingcart"
                                     emptyMessage="No rewards to display"
                                     >
                                        <p:column style="width: 10%">
                                            <f:facet name="header">Reward ID</f:facet>
                                        #{o.id}
                                        </p:column>

                                        <p:column style="width: 20%">
                                            <f:facet name="header">Name</f:facet>
                                        #{o.reward_Name}
                                        </p:column>

                                        <p:column style="width: 30%">
                                            <f:facet name="header">Description</f:facet>
                                        <h:outputText value="#{o.reward_Description}" escape="false"/>
                                        </p:column> 

                                        <p:column style="width: 10%">
                                            <f:facet name="header">Points Cost</f:facet>
                                        #{o.reward_Cost}
                                        </p:column> 

                                        <p:column style="width: 10%">
                                            <f:facet name="header">Vouchers Available</f:facet>
                                        #{o.getRemainingVouchers()}
                                        </p:column>
                                         
                                        <p:column style="width: 20%">
                                            <p:commandButton  value="Buy this Reward!" action ="BuyVoucherComplete.xhtml?faces-redirect=true" actionListener="#{fakeMainPortalMB.buyRewardVoucher(o.id)}"/>     
           
                                        </p:column> 
                                     </p:dataTable>
                                <br/>
                 
                                
                                
            </div>   
        </h:form>
        
        
        <br/>
        <br/>
        <br/>
        

    </h:body>
</html>